package com.zone.gateway.sdk.config;

import com.zone.gateway.sdk.domain.service.ApplicationConfigRegisManageService;
import com.zone.gateway.sdk.domain.service.RedisMessageService;
import com.zone.gateway.sdk.listener.ApplicationStartedCustomerListener;
import com.zone.gateway.sdk.postProcess.ApiProductBeanPostProcess;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;

/**
 * @author: zongzi
 * @description: TODO
 * @date: 2025/4/29
 */
@Configuration
@EnableConfigurationProperties(ApiGatewaySdkProperties.class)
public class ApiGatewaySdkConfiguration {

    private final ApiGatewaySdkProperties properties;

    public ApiGatewaySdkConfiguration(ApiGatewaySdkProperties properties) {
        this.properties = properties;
    }


    @Bean
    public ApplicationConfigRegisManageService applicationConfigRegisManageService() {
        return new ApplicationConfigRegisManageService(properties);
    }

    @Bean
    @DependsOn("applicationConfigRegisManageService")
    public ApiProductBeanPostProcess apiProductBeanPostProcess(ApplicationConfigRegisManageService applicationConfigRegisManageService) {
        return new ApiProductBeanPostProcess(applicationConfigRegisManageService, properties);
    }

    @Bean
    public RedisMessageService redisMessageService() {
        return new RedisMessageService();
    }

    @Bean
    @DependsOn("redisMessageService")
    public ApplicationStartedCustomerListener applicationStartedCustomerListener(RedisMessageService redisMessageService) {
        return new ApplicationStartedCustomerListener(properties, redisMessageService);
    }
}
